/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2010
 */

package com.hibernate.model;


import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import cn.org.rapid_framework.util.DateConvertUtils;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "MATERIAL")
public class Material extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "物料";
	public static final String ALIAS_ID = "id";
	public static final String ALIAS_PLAN_ID = "所属计划";
	public static final String ALIAS_TYPE_ID = "类型";
	public static final String ALIAS_NAME = "名称";
	public static final String ALIAS_CLICK_TYPE = "点击类型";
	public static final String ALIAS_PATH = "路径";
	public static final String ALIAS_WIDTH = "宽";
	public static final String ALIAS_HEIGTH = "高";
	public static final String ALIAS_STATUS = "状态";
	public static final String ALIAS_LZ_URL = "lzUrl";////add by wangweiwei 量子统计地址 2011/9/28
	public static final String ALIAS_BUOYPATH = "浮标 url";
	public static final String ALIAS_ISSHOWPY = "是否显示品友播放框";
	public static final String ALIAS_OTHER_CODE = "外部编号";
	public static final String ALIAS_PEOPLE_SEX = "性别";
	public static final String ALIAS_IMG_SITE = "图像位置";
	public static final String ALIAS_IMG_COLOUR = "图像颜色";
	public static final String ALIAS_TEXT_SITE = "文字位置";
	public static final String ALIAS_TEXT_COLOUR = "文字颜色";
	public static final String ALIAS_TEXT_CONTENT_TYPE = "文字内容类型";
	public static final String ALIAS_BG_COLOUR = "底色调";
	public static final String ALIAS_ANIMATION_TYPE = "动画特效";
	public static final String ALIAS_IS_RIGHT = "是否存在问题";
	public static final String ALIAS_ENTIRE_STYLE = "整体风格";
	
	//date formats
	public static final String FORMAT_START_TIME = DATE_FORMAT;
	public static final String FORMAT_END_TIME = DATE_FORMAT;
	public static final String FORMAT_CREATION_TIME = DATE_TIME_FORMAT;
	
	public static final String FORMAT_START_TIME_SLOT = TIME_FORMAT;
	public static final String FORMAT_END_TIME_SLOT = TIME_FORMAT;
	
	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
	
	private Long id;
	@NotNull 
	private Long planId;
	@NotNull 
	private Long typeId;
	@Length(max=255)
	private String otherCode;
	@NotBlank @Length(max=50)
	private java.lang.String name;
	@NotBlank @Length(max=1)
	private java.lang.String clickType;
	@NotBlank @Length(max=200)
	private java.lang.String path;
	
	private java.lang.String buoypath;

	private java.lang.String width;
	
	private java.lang.String height;
	
	/**
	 * 1开启，2停用,3删除
	 */
	private java.lang.String status;
	
	private java.lang.String isShowPy;
	
	

	/**
     * 性别       db_column: PEOPLE_SEX 
     */ 	
	@Length(max=2)
	private java.lang.String peopleSex;
    /**
     * 图像位置       db_column: IMG_SITE 
     */ 	
	@Length(max=10)
	private java.lang.String imgSite;
    /**
     * 图像颜色       db_column: IMG_COLOUR 
     */ 	
	@Length(max=50)
	private java.lang.String imgColour;
    /**
     * 文字位置       db_column: TEXT_SITE 
     */ 	
	@Length(max=10)
	private java.lang.String textSite;
    /**
     * 文字颜色       db_column: TEXT_COLOUR 
     */ 	
	@Length(max=50)
	private java.lang.String textColour;
    /**
     * 文字内容类型       db_column: TEXT_CONTENT_TYPE 
     */ 	
	@Length(max=50)
	private java.lang.String textContentType;
    /**
     * 底色调       db_column: BG_COLOUR 
     */ 	
	@Length(max=50)
	private java.lang.String bgColour;
    /**
     * 动画特效       db_column: ANIMATION_TYPE 
     */ 	
	@Length(max=50)
	private java.lang.String animationType;
    /**
     * 是否存在问题       db_column: IS_RIGHT 
     */ 	
	@Length(max=10)
	private java.lang.String isRight;
    /**
     * 整体风格       db_column: ENTIRE_STYLE 
     */ 	
	@Length(max=50)
	private java.lang.String entireStyle;
	
	
	private java.util.Date creationTime;
	
	//columns END


	public Material(){
	}

	public Material(
		Long id
	){
		this.id = id;
	}

	
	@Column(name = "WIDTH")
	public java.lang.String getWidth() {
		return width;
	}

	public void setWidth(java.lang.String width) {
		this.width = width;
	}

	@Column(name = "HEIGTH")
	public java.lang.String getHeight() {
		return height;
	}

	public void setHeight(java.lang.String height) {
		this.height = height;
	}	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "PLAN_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getPlanId() {
		return this.planId;
	}
	
	public void setPlanId(Long value) {
		this.planId = value;
	}
	
	@Column(name = "ISSHOWPY")
	public java.lang.String getIsShowPy() {
		return isShowPy;
	}

	public void setIsShowPy(java.lang.String isShowPy) {
		this.isShowPy = isShowPy;
	}

	@Column(name = "TYPE_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getTypeId() {
		return this.typeId;
	}
	
	public void setTypeId(Long value) {
		this.typeId = value;
	}
	
	@Column(name = "NAME", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "STATUS")
	public java.lang.String getStatus() {
		return status;
	}

	public void setStatus(java.lang.String status) {
		this.status = status;
	}
	
	//begin add by wangweiwei 量子统计URL 2011/9/28
	private java.lang.String lzUrl;
	@Column(name="LZ_URL" ,unique=false, insertable = true, updatable = true, length = 1000)
	public java.lang.String getLzUrl(){
		return this.lzUrl;
	}

	public void setLzUrl(java.lang.String value){
		this.lzUrl = value;
	}
	//end
	
	@Column(name = "CLICK_TYPE", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
	public java.lang.String getClickType() {
		return this.clickType;
	}
	
	public void setClickType(java.lang.String value) {
		this.clickType = value;
	}
	
	@Column(name = "PATH", unique = false, nullable = false, insertable = true, updatable = true, length = 200)
	public java.lang.String getPath() {
		return this.path;
	}
	
	public void setPath(java.lang.String value) {
		this.path = value;
	}
	
	@Column(name = "BUOYPATH", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getBuoypath() {
		return buoypath;
	}

	public void setBuoypath(java.lang.String buoypath) {
		this.buoypath = buoypath;
	}
	
	private Set materialSitePlays = new HashSet(0);
	public void setMaterialSitePlays(Set<MaterialSitePlay> materialSitePlay){
		this.materialSitePlays = materialSitePlay;
	}
	
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "material")
	public Set<MaterialSitePlay> getMaterialSitePlays() {
		return materialSitePlays;
	}
	
	private MaterialType materialType;
	public void setMaterialType(MaterialType materialType){
		this.materialType = materialType;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "TYPE_ID",nullable = false, insertable = false, updatable = false) 
	})
	public MaterialType getMaterialType() {
		return materialType;
	}
	
	private AdPlan adPlan;
	public void setAdPlan(AdPlan adPlan){
		if(adPlan != null)
			adPlan.getName();
		this.adPlan = adPlan;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "PLAN_ID",nullable = false, insertable = false, updatable = false) 
	})
	public AdPlan getAdPlan() {
		return adPlan;
	}
	@Column(name = "OTHER_CODE", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public String getOtherCode() {
		return this.otherCode;
	}
	
	public void setOtherCode(String value) {
		this.otherCode = value;
	}
	

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Material == false) return false;
		if(this == obj) return true;
		Material other = (Material)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}

	@Column(name = "PEOPLE_SEX", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public java.lang.String getPeopleSex() {
		return this.peopleSex;
	}
	
	public void setPeopleSex(java.lang.String value) {
		this.peopleSex = value;
	}
	
	@Column(name = "IMG_SITE", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.String getImgSite() {
		return this.imgSite;
	}
	
	public void setImgSite(java.lang.String value) {
		this.imgSite = value;
	}
	
	@Column(name = "IMG_COLOUR", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getImgColour() {
		return this.imgColour;
	}
	
	public void setImgColour(java.lang.String value) {
		this.imgColour = value;
	}
	
	@Column(name = "TEXT_SITE", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.String getTextSite() {
		return this.textSite;
	}
	
	public void setTextSite(java.lang.String value) {
		this.textSite = value;
	}
	
	@Column(name = "TEXT_COLOUR", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getTextColour() {
		return this.textColour;
	}
	
	public void setTextColour(java.lang.String value) {
		this.textColour = value;
	}
	
	@Column(name = "TEXT_CONTENT_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getTextContentType() {
		return this.textContentType;
	}
	
	public void setTextContentType(java.lang.String value) {
		this.textContentType = value;
	}
	
	@Column(name = "BG_COLOUR", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getBgColour() {
		return this.bgColour;
	}
	
	public void setBgColour(java.lang.String value) {
		this.bgColour = value;
	}
	
	@Column(name = "ANIMATION_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getAnimationType() {
		return this.animationType;
	}
	
	public void setAnimationType(java.lang.String value) {
		this.animationType = value;
	}
	
	@Column(name = "IS_RIGHT", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.String getIsRight() {
		return this.isRight;
	}
	
	public void setIsRight(java.lang.String value) {
		this.isRight = value;
	}
	
	@Column(name = "ENTIRE_STYLE", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getEntireStyle() {
		return this.entireStyle;
	}
	
	public void setEntireStyle(java.lang.String value) {
		this.entireStyle = value;
	}	
	
	@Column(name = "CREATION_TIME", unique = false, insertable = true, length = 7)
	public java.util.Date getCreationTime() {
		return this.creationTime;
	}
	
	public void setCreationTime(java.util.Date value) {
		this.creationTime = value;
	}
	
	@Transient
	public String getCreationTimeString() {
		return DateConvertUtils.format(getCreationTime(), FORMAT_CREATION_TIME);
	}
	public void setCreationTimeString(String value) {
		setCreationTime(DateConvertUtils.parse(value, FORMAT_CREATION_TIME,java.util.Date.class));
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return "物料表";
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return getId();
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return getName();
	}
}

